<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>LibTools: H:/project/LibTools/src/socket/SockTools.cpp 文件参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">LibTools
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.16 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','搜索');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_9ad1227260954e346101f3844f0abb3d.html">socket</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#define-members">宏定义</a> &#124;
<a href="#func-members">函数</a>  </div>
  <div class="headertitle">
<div class="title">SockTools.cpp 文件参考</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="_sock_tools_8h_source.html">SockTools.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="_sock_data_8h_source.html">./internal/SockData.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="_socket_8h_source.html">./internal/Socket.h</a>&quot;</code><br />
<code>#include &lt;arpa/inet.h&gt;</code><br />
</div>
<p><a href="_sock_tools_8cpp_source.html">浏览源代码.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
宏定义</h2></td></tr>
<tr class="memitem:adfc8f90f3a8caa8423099cf36ff214f1"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="_sock_tools_8cpp.html#adfc8f90f3a8caa8423099cf36ff214f1">_WINSOCK_DEPRECATED_NO_WARNINGS</a></td></tr>
<tr class="separator:adfc8f90f3a8caa8423099cf36ff214f1"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
函数</h2></td></tr>
<tr class="memitem:a428b978a56ae9d9461b9db1347e0cad2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="tools_8h.html#a201ce692c9dca6599e5c12d00167419b">DEF_BEG_LIBTOOLS</a> unsigned <a class="el" href="_find_file_8h.html#a37cc1038758216808d5f75090b093c9a">int</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="_sock_tools_8cpp.html#a428b978a56ae9d9461b9db1347e0cad2">HostByteOrder</a> ()</td></tr>
<tr class="memdesc:a428b978a56ae9d9461b9db1347e0cad2"><td class="mdescLeft">&#160;</td><td class="mdescRight">判断大端还是小端字节序  <a href="_sock_tools_8cpp.html#a428b978a56ae9d9461b9db1347e0cad2">更多...</a><br /></td></tr>
<tr class="separator:a428b978a56ae9d9461b9db1347e0cad2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac5273d06745110e78bca129577ab2d06"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_c_sock_error.html">CSockError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="_sock_tools_8cpp.html#ac5273d06745110e78bca129577ab2d06">Bind</a> (<a class="el" href="class_c_socket.html">CSocket</a> &amp;sock, const char *szAddr, <a class="el" href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a> port)</td></tr>
<tr class="memdesc:ac5273d06745110e78bca129577ab2d06"><td class="mdescLeft">&#160;</td><td class="mdescRight">绑定套接字端口  <a href="_sock_tools_8cpp.html#ac5273d06745110e78bca129577ab2d06">更多...</a><br /></td></tr>
<tr class="separator:ac5273d06745110e78bca129577ab2d06"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abface14c5278330909dd390d3d5a4332"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_c_sock_error.html">CSockError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="_sock_tools_8cpp.html#abface14c5278330909dd390d3d5a4332">Listen</a> (<a class="el" href="class_c_socket.html">CSocket</a> &amp;sock, <a class="el" href="_find_file_8h.html#a37cc1038758216808d5f75090b093c9a">int</a> backlog)</td></tr>
<tr class="memdesc:abface14c5278330909dd390d3d5a4332"><td class="mdescLeft">&#160;</td><td class="mdescRight">监听套接字  <a href="_sock_tools_8cpp.html#abface14c5278330909dd390d3d5a4332">更多...</a><br /></td></tr>
<tr class="separator:abface14c5278330909dd390d3d5a4332"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a94adf0712e04454717a4327e9061bdf8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_c_sock_error.html">CSockError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="_sock_tools_8cpp.html#a94adf0712e04454717a4327e9061bdf8">GetSockName</a> (const <a class="el" href="class_c_socket.html">CSocket</a> &amp;sock, <a class="el" href="class_c_sock_addr.html">CSockAddr</a> &amp;addr)</td></tr>
<tr class="memdesc:a94adf0712e04454717a4327e9061bdf8"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取套接口本地名字  <a href="_sock_tools_8cpp.html#a94adf0712e04454717a4327e9061bdf8">更多...</a><br /></td></tr>
<tr class="separator:a94adf0712e04454717a4327e9061bdf8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">宏定义说明</h2>
<a id="adfc8f90f3a8caa8423099cf36ff214f1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adfc8f90f3a8caa8423099cf36ff214f1">&#9670;&nbsp;</a></span>_WINSOCK_DEPRECATED_NO_WARNINGS</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define _WINSOCK_DEPRECATED_NO_WARNINGS</td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">在文件 <a class="el" href="_sock_tools_8cpp_source.html">SockTools.cpp</a> 第 <a class="el" href="_sock_tools_8cpp_source.html#l00001">1</a> 行定义.</p>

</div>
</div>
<h2 class="groupheader">函数说明</h2>
<a id="ac5273d06745110e78bca129577ab2d06"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac5273d06745110e78bca129577ab2d06">&#9670;&nbsp;</a></span>Bind()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_c_sock_error.html">CSockError</a> Bind </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="class_c_socket.html">CSocket</a> &amp;&#160;</td>
          <td class="paramname"><em>sock</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>szAddr</em> = <code><a class="el" href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a></code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a>&#160;</td>
          <td class="paramname"><em>port</em> = <code>-1</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>绑定套接字端口 </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">sock</td><td>已创建的套接字 </td></tr>
    <tr><td class="paramname">szAddr</td><td>绑定的地址 </td></tr>
    <tr><td class="paramname">port</td><td>绑定的端口 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>成功返回CSockError::succ,失败返回相应的错误码 </dd></dl>
<dl class="section remark"><dt>备注</dt><dd>若szAddr为null或port为-1则会通过sock获取到地址和端口，否则为sock端口、地址进行赋值 </dd></dl>

<p class="definition">在文件 <a class="el" href="_sock_tools_8cpp_source.html">SockTools.cpp</a> 第 <a class="el" href="_sock_tools_8cpp_source.html#l00033">33</a> 行定义.</p>

</div>
</div>
<a id="a94adf0712e04454717a4327e9061bdf8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a94adf0712e04454717a4327e9061bdf8">&#9670;&nbsp;</a></span>GetSockName()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_c_sock_error.html">CSockError</a> GetSockName </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_c_socket.html">CSocket</a> &amp;&#160;</td>
          <td class="paramname"><em>sock</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="class_c_sock_addr.html">CSockAddr</a> &amp;&#160;</td>
          <td class="paramname"><em>addr</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>获取套接口本地名字 </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">sock</td><td>套接口类 </td></tr>
    <tr><td class="paramname">addr</td><td>地址结构信息 </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">在文件 <a class="el" href="_sock_tools_8cpp_source.html">SockTools.cpp</a> 第 <a class="el" href="_sock_tools_8cpp_source.html#l00077">77</a> 行定义.</p>

</div>
</div>
<a id="a428b978a56ae9d9461b9db1347e0cad2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a428b978a56ae9d9461b9db1347e0cad2">&#9670;&nbsp;</a></span>HostByteOrder()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="tools_8h.html#a201ce692c9dca6599e5c12d00167419b">DEF_BEG_LIBTOOLS</a> unsigned <a class="el" href="_find_file_8h.html#a37cc1038758216808d5f75090b093c9a">int</a> HostByteOrder </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>判断大端还是小端字节序 </p>
<dl class="section return"><dt>返回</dt><dd>BIG_ENDIAN大端字节序，LITTER_ENDIAN小端字节序 </dd></dl>

<p class="definition">在文件 <a class="el" href="_sock_tools_8cpp_source.html">SockTools.cpp</a> 第 <a class="el" href="_sock_tools_8cpp_source.html#l00015">15</a> 行定义.</p>

</div>
</div>
<a id="abface14c5278330909dd390d3d5a4332"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abface14c5278330909dd390d3d5a4332">&#9670;&nbsp;</a></span>Listen()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_c_sock_error.html">CSockError</a> Listen </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="class_c_socket.html">CSocket</a> &amp;&#160;</td>
          <td class="paramname"><em>sock</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="_find_file_8h.html#a37cc1038758216808d5f75090b093c9a">int</a>&#160;</td>
          <td class="paramname"><em>backlog</em> = <code>SOMAXCONN</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>监听套接字 </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">sock</td><td>已创建的套接字 </td></tr>
    <tr><td class="paramname">backlog</td><td>监听的最大数量 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>成功返回CSockError::succ,失败返回相应的错误码 </dd></dl>

<p class="definition">在文件 <a class="el" href="_sock_tools_8cpp_source.html">SockTools.cpp</a> 第 <a class="el" href="_sock_tools_8cpp_source.html#l00067">67</a> 行定义.</p>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者 &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.16
</small></address>
</body>
</html>
